package cn.jdx.tools.md8ok;


import cn.jdx.tools.md2html.Md2Html;
import cn.jdx.tools.md4img.Md4Img;
import cn.jdx.tools.zip.JdxZipFile;

import java.io.File;

public class MdToHtml {
    public static String start(String mdPath) {
        //【1】.处理md文档中的所有img标签
        Md4Img md4Img = new Md4Img();
        String outputPath = md4Img.start(mdPath);
        System.out.println("[处理路径]:"+outputPath);
        //【2】.生成好看的html文档
        Md2Html md2Html = new Md2Html();
        String pathTo = md2Html.start(outputPath);
        //【3】.压缩该目录
        File file = new File(outputPath);
        File parentFile = file.getParentFile();
        String inDir = parentFile.getAbsolutePath();
        String zipFileName = parentFile.getName()+".zip";

        String outZip = new File(new File(inDir).getParentFile(),zipFileName).getAbsolutePath();

        JdxZipFile.zipFile(inDir,outZip);
        System.out.println("[MdToHtml.start]:"+outZip);
        return pathTo;
    }

}

